package com.qf.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.entity.User;
import com.qf.mapper.UserMapper;
import com.qf.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author TZL
 * @date 2020/8/6
 */
@Service
@Transactional//自动管理事务
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
//    @Override
//    public List<User> queryAllUsers(int page,int limit) {
//        List<User> users = userMapper.queryAllUsers(page,limit);
//        return users;
//    }

//    @Override
//    public PageInfo<User> queryAllUsers(int page, int limit) {
//        PageHelper.startPage(page,limit);
//        List<User> users = userMapper.queryAllUsers();
//        return new PageInfo<User>(users);
//    }

    @Override
    public List<User> queryAllUsers(int page, int limit) {
        List<User> users = userMapper.queryAllUsers(page, limit);
        return users;
    }

    @Override
    public int usercount() {
        int usercount = userMapper.usercount();
        return usercount;
    }

    @Override
    public int updateUser(User user) {
        return userMapper.updateUser(user);
    }

    @Override
    public int deleteUser(int id) {
        return userMapper.deleteUser(id);
    }

    @Override
    public int insertUser(User user) {
        return userMapper.insertUser(user);
    }
}
